# Product类，表示最终构建的产品
class Product:
    def __init__(self):
        self.parts = []

    def add_part(self, part):
        self.parts.append(part)

    def show(self):
        print("Product Parts:", ", ".join(self.parts))


# Builder抽象类
class Builder:
    def build_part_a(self):
        pass

    def build_part_b(self):
        pass

    def build_part_c(self):
        pass

    def get_result(self):
        pass


# ConcreteBuilder类，Builder的具体实现
class ConcreteBuilder(Builder):
    def __init__(self):
        self.product = Product()

    def build_part_a(self):
        self.product.add_part("Part A")

    def build_part_b(self):
        self.product.add_part("Part B")

    def build_part_c(self):
        self.product.add_part("Part C")

    def get_result(self):
        return self.product


# Director类，使用Builder对象来构建Product
class Director:
    def __init__(self, builder: Builder):
        self.builder = builder

    def construct(self):
        self.builder.build_part_a()
        self.builder.build_part_b()
        self.builder.build_part_c()


# 客户端代码
if __name__ == "__main__":
    # 创建一个ConcreteBuilder对象
    builder = ConcreteBuilder()

    # 创建一个Director对象，并传入ConcreteBuilder
    director = Director(builder)

    # 导演按照构建步骤构建产品
    director.construct()

    # 获取构建好的产品
    product = builder.get_result()

    # 显示产品
    product.show()